package com.tsystems.entities;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;


@Entity
public class Train implements Serializable {


	private static final long serialVersionUID = 3818435830278537978L;
	
	@Id
	private String id;
	
	@PrePersist
	public void prepareId() {
		if (id == null) {
			id = UUID.randomUUID().toString();
		}
	}
	
	
	@Column(unique = true)
	private String number;
	
	
	private long seats;
	
	@OneToMany(mappedBy = "train")
	private List<TimeTableElement> timeTableElements;
	

	
	public Train() {

	}
	
	public Train(String number, long seats) {
		super();
		this.number=number;
		this.seats =seats;
	}
	
	
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public long getSeats() {
		return seats;
	}

	public void setSeats(long seats) {
		this.seats = seats;
	}

	public List<TimeTableElement> getTimeTableElements() {
		return timeTableElements;
	}

	public void setTimeTableElements(List<TimeTableElement> timeTableElements) {
		this.timeTableElements = timeTableElements;
	}

	@Override
	public String toString() {
		return number;
	}

	
	
	
}
